/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package questao06;

public class Joystick {
    private static final int QTDSLOTS = 3;
    
    private Command[] botaoA;
    private Command[] botaoB;
    
    public Joystick() {
        botaoA = new Command[QTDSLOTS];
        botaoB = new Command[QTDSLOTS];
        
        NoCommand noCommand = new NoCommand();
        for(int slot = 0; slot < QTDSLOTS; slot++) {
            botaoA[slot] = botaoB[slot] = noCommand;
        }
    }
    
    public void setCommand(int slot, Command botaoACommand, Command botaoBCommand) {
        botaoA[slot] = botaoACommand;
        botaoB[slot] = botaoBCommand;
    } 
    
    public void pressionarBotaoA(int slot) {
        System.out.println("Botão 'A' pressionado.");
        botaoA[slot].execute();
    }
    
    public void pressionarBotaoB(int slot) {
        System.out.println("Botão 'B' pressionado.");
        botaoB[slot].execute();
    }
}
